
package ru.samgtu.wst.ui.swing;

import ru.samgtu.wst.model.ConversationID;
import ru.samgtu.wst.model.ConversationModel;
import ru.samgtu.wst.model.FilteredConversationModel;
import ru.samgtu.wst.model.FrameworkModel;
import ru.samgtu.wst.model.HttpUrl;


public class UrlFilteredConversationModel extends FilteredConversationModel {

	private ConversationModel _model;
	private HttpUrl _url = null;

	/** Creates a new instance of UrlFilteredConversationModel */
	public UrlFilteredConversationModel(FrameworkModel model,
			ConversationModel cmodel) {
		super(model, cmodel);
		_model = cmodel;
	}

	public void setUrl(HttpUrl url) {
		if (url == _url) {
			return;
		} else if (((_url == null) && (url != null))
				|| ((_url != null) && (url == null)) || !_url.equals(url)) {
			_url = url;
			updateConversations();
		}
	}

	@Override
	public boolean shouldFilter(ConversationID id) {
		if (_url == null) {
			return false;
		} else {
			return !_url.equals(_model.getRequestUrl(id));
		}
	}

}
